{extend name="personcentor/information"}
{block name="main"}
 <!--上传图片插件开始-->
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script>
    //图片上传预览    IE是用了滤镜。
    function previewImage(file)
    {
        var MAXWIDTH  = 90;
        var MAXHEIGHT = 90;
        var div = document.getElementById('preview');
        if (file.files && file.files[0])
        {
            div.innerHTML ='<img id=imghead onclick=$("#previewImg").click()>';
            var img = document.getElementById('imghead');
            img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
//                 img.style.marginLeft = rect.left+'px';
                img.style.marginTop = rect.top+'px';
            }
            var reader = new FileReader();
            reader.onload = function(evt){img.src = evt.target.result;}
            reader.readAsDataURL(file.files[0]);
        }
        else //兼容IE
        {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead>';
            var img = document.getElementById('imghead');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
        }
    }
    function clacImgZoomParam( maxWidth, maxHeight, width, height ){
        var param = {top:0, left:0, width:width, height:height};
        if( width>maxWidth || height>maxHeight ){
            rateWidth = width / maxWidth;
            rateHeight = height / maxHeight;

            if( rateWidth > rateHeight ){
                param.width =  maxWidth;
                param.height = Math.round(height / rateWidth);
            }else{
                param.width = Math.round(width / rateHeight);
                param.height = maxHeight;
            }
        }
        param.left = Math.round((maxWidth - param.width) / 2);
        param.top = Math.round((maxHeight - param.height) / 2);
        return param;
    }
</script>
<!--上传图片插件结束-->
<div class="col-main">
    <div class="main-wrap">
        <br/>
        <br/>
        <br/>
        <div class="">
            <h3 style="margin-left: 40%;">编辑商家信息</h3>
            <form class="form-horizontal" method="post" action="{:url('index/business/goodsinformationupdate')}" enctype="multipart/form-data">
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-2 control-label">选择商家类型:</label>
                <label class="radio-inline">
                    <input type="radio" name="usertype" id="inlineRadio1" value="0" {if condition="$goodresource.usertype eq 0 "} checked {/if}> 用户
                </label>
                <label class="radio-inline">
                    <input type="radio" name="usertype" id="inlineRadio2" value="1" {if condition="$goodresource.usertype eq 1 "} checked {/if}> 商家
                </label>
                </div>


                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-2 control-label">联系人名字:</label>
                    <div class="col-sm-10">
                        <input type="text" name="link_name" class="form-control" id="inputEmail3" value="{$goodresource.link_name}"  >
                        <input type="hidden" name="audit" value="0"/>
                        <input type="hidden" name="id" value="{$goodresource.id}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputPassword3"  class="col-sm-2 control-label">联系人电话:</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="link_phone" value="{$goodresource.link_phone}" >
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputPassword3"  class="col-sm-2 control-label">身份证名/企业名:</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="name_company" id="inputPassword3" value="{$goodresource.name_company}" >
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputPassword3"  class="col-sm-2 control-label">企业执照号/身份证:</label>
                    <div class="col-sm-10">
                        <input type="text" name="id_reg" class="form-control"   value="{$goodresource.id_reg}">
                    </div>
                </div>

                <div class="col-sm-2 big-photo" style="margin-left: 30%;">
                    <div id="preview">
                        <img id="imghead" border="0" src="/uploads/business/{:str_replace('\','/',$goodresource.ros_charter)}" style="width:100px;height:100px;" onclick="$('#previewImg').click();">
                    </div>
                    <input type="file" onchange="previewImage(this)" style="display: none;" id="previewImg"  name="image">
                </div>
                   <br/>
                   <br/>
                <div class="form-group" style="margin-left: 30%;">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-info">确认修改</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block}
